//package com.ruoyi.ora.service.impl;
//
//import com.ruoyi.common.enums.dict.AiModel;
//import com.ruoyi.ora.constant.BizConstants;
//import com.ruoyi.ora.domain.ChatResponse;
//import com.ruoyi.ora.service.IAiInterfaceService;
//import com.ruoyi.system.service.ISysConfigService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.HttpEntity;
//import org.springframework.http.HttpHeaders;
//import org.springframework.http.MediaType;
//import org.springframework.stereotype.Service;
//import org.springframework.web.client.RestTemplate;
//
////@Service("chatMygptlifeService")
//@Service
//public class ChatMygptlifeServiceImpl implements IAiInterfaceService {
//
//    @Autowired
//    private RestTemplate restTemplate;
//    @Autowired
//    private ISysConfigService sysConfigService;
//
//    @Override
//    public String chatCompletions(String prompt) {
//        return "";
//    }
//
//    @Override
//    public ChatResponse getChatCompletions(String prompt) {
//        return this.getChatCompletions(prompt, AiModel.GPT35_TURBO);
//    }
//
//    @Override
//    public ChatResponse getChatCompletions(String prompt, AiModel aiModel) {
//        String url = sysConfigService.selectConfigByKey(BizConstants.Redis.SysConfig.MYGPTLIFE_API_URL);
//        String data = "{\"model\":\""+ aiModel.getValue()+"\",\"messages\":[{\"role\":\"user\",\"content\":\"" + prompt + "\"}]}";
//        String mygptlifeApiKey = sysConfigService.selectConfigByKey(BizConstants.Redis.SysConfig.MYGPTLIFE_API_KEY);
//        HttpHeaders headers = new HttpHeaders();
//        headers.set("Authorization", "Bearer "+mygptlifeApiKey);
//        headers.setContentType(MediaType.APPLICATION_JSON); // 如果需要设置内容类型
//        HttpEntity<Object> entity = new HttpEntity<>(data, headers);
//        return restTemplate.postForObject(url, entity, ChatResponse.class);
//    }
//
//    @Override
//    public ChatResponse getChatCompletionsTran(String json) {
//        String url = sysConfigService.selectConfigByKey(BizConstants.Redis.SysConfig.MYGPTLIFE_API_URL);
//        String mygptlifeApiKey = sysConfigService.selectConfigByKey(BizConstants.Redis.SysConfig.MYGPTLIFE_API_KEY);
//        HttpHeaders headers = new HttpHeaders();
//        headers.set("Authorization", "Bearer "+mygptlifeApiKey);
//        headers.setContentType(MediaType.APPLICATION_JSON); // 如果需要设置内容类型
//        HttpEntity<Object> entity = new HttpEntity<>(json, headers);
//        ChatResponse chatResponse = restTemplate.postForObject(url, entity, ChatResponse.class);
//
//        return chatResponse;
//    }
//
//    @Override
//    public ChatResponse getChatCompletionsTran1(String json) {
//
//        json = "{\n" +
//                "           \"model\": \"deepseek-r1:1.5b\",\n" +
//                "           \"prompt\": \"用一句话解释量子计算\",\n" +
//                "           \"stream\": false\n" +
//                "         }";
//        HttpHeaders headers = new HttpHeaders();
//        headers.setContentType(MediaType.APPLICATION_JSON); // 如果需要设置内容类型
//        HttpEntity<Object> entity = new HttpEntity<>(json, headers);
//        ChatResponse chatResponse = restTemplate.postForObject("https://fugfrx-qcrzhh-8434.app.cloudstudio.work", entity, ChatResponse.class);
//        System.out.println(chatResponse);
//        return null;
//    }
//}
